package com.yz.android18_tweenanimation;

import android.content.Context;
import android.support.v4.provider.DocumentFile;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class NextActivity extends AppCompatActivity {
    private Context mContext = this;
    private ImageView imageView_main;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        imageView_main = (ImageView) findViewById(R.id.imageView_main);

    }

    public void clickView(View view) {
        Animation animation = null;
        switch (view.getId()) {
            case R.id.button_alpha:
                animation = new AlphaAnimation(1.0f, 0.0f);
                break;
            case R.id.button_rotate:
                animation = new RotateAnimation(0.0f, 250f, 1, 0.5f, 1, 0.5f);
                break;
            case R.id.button_scale:
                animation = new ScaleAnimation(0, 1, 0, 1, 1, 0.5f, 1, 0.5f);
                break;
            case R.id.button_translate:
                animation = new TranslateAnimation(0, 0, 500, 0);
                break;
            case R.id.button_set:
                break;
        }
        animation.setDuration(300);
        animation.setRepeatCount(Animation.INFINITE);//常量值为-1
        animation.setRepeatMode(Animation.REVERSE);

        imageView_main.startAnimation(animation);
    }
}
